Fix kraus channels for fallbacks to super-operators#7537
Merged
mhucka merged 5 commits intoquantumlib:mainfrom Jul 25, 2025
Merged
Fix kraus channels for fallbacks to super-operators#7537mhucka merged 5 commits intoquantumlib:mainfrom
mhucka merged 5 commits intoquantumlib:mainfrom
Conversation
- There were a few issues with the new strategy to fall back to super-operator calculations using apply_channels. - First, the super_operator_to_kraus function is generally not precise or numerically stable enough to support an atol of 1e-10 so loosened this to 1e-6 and also allowed the ability to specify this as a parameter. - Next, some operators define decomposition, so cirq.kraus should try to decompose and get a unitary before falling back to using apply_channel.
mhucka
requested changes
Jul 25, 2025
Contributor
mhucka
left a comment
There was a problem hiding this comment.
LGTM with requests for some minor docstring adjustments.
| default: Determines the fallback behavior when `val` doesn't have | ||
| a channel. If `default` is not set, a TypeError is raised. If | ||
| default is set to a value, that value is returned. | ||
| atol: If calculating kraus channels from channels, use this tolerance |
|
|
||
|
|
||
| def test_kraus_channel_with_has_unitary(): | ||
| """CZSWAP is a gate with no unitary but has a unitary.""" |
Contributor
There was a problem hiding this comment.
I think there is something wrong with this docstring ;-)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7537 +/- ##
==========================================
- Coverage 97.53% 97.53% -0.01%
==========================================
Files 1095 1095
Lines 99006 99014 +8
==========================================
+ Hits 96570 96576 +6
- Misses 2436 2438 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Aug 5, 2025
pavoljuhas
pushed a commit
that referenced
this pull request
Aug 14, 2025
- There were a few issues with the new strategy to fall back to super-operator calculations using apply_channels. - First, the super_operator_to_kraus function is generally not precise or numerically stable enough to support an atol of 1e-10 so loosened this to 1e-6 and also allowed the ability to specify this as a parameter. - Next, some operators define decomposition, so cirq.kraus should try to decompose and get a unitary before falling back to using apply_channel. Fixes: #7536
This was referenced Jan 12, 2026
Create an Gateset.__ini__ option to accept classically controlled operations
NoureldinYosri/Cirq#267
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #7536